import datetime


def saveChar(mydb, data):
    now = datetime.datetime.now()
    char = {}
    char['name'] = data['name']
    char['code'] = data['code']
    char['tenant_id'] = 0
    char['create_by'] = 'admin'
    char['create_time'] = now
    char['update_by'] = 'admin'
    char['update_time'] = char['create_time']
    charTuple = (char['name'], char['code'],
                 char['tenant_id'], char['create_by'],
                 char['create_time'], char['update_by'],
                 char['update_time'])

    mycursor = mydb.cursor()

    sql = "INSERT INTO wiki_dict_char  \
    (name,code, tenant_id,create_by, create_time, update_by, update_time) \
    VALUES (%s, %s, %s, %s, %s, %s, %s);"
    mycursor.execute(sql, charTuple)

    mycursor.close

    mydb.commit()

